package acwing.二分;

import java.util.Scanner;

/**
 * 递增三元组
 *
 * @author yang
 * @date 2021/11/25
 */
public class 递增三元组 {

    static int N = 100010;
    static int[] a = new int[N];
    static int[] b = new int[N];
    static int[] c = new int[N];
    static int[] acnt = new int[N];//acnt[i]表示在A中i这个值出现多少次
    static int[] ccnt = new int[N];//ccnt[i]表示在C中i这个值出现多少次
    static int[] as = new int[N];//记录在A中由多少个数小于B[i]
    static int[] cs = new int[N];//记录在C中由多少个数大于B[i]
    static int[] s = new int[N];//求从1到i中,所有数出现的次数的前缀和


    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        for (int i = 0; i < n; i++) a[i] = sc.nextInt() + 1;
        for (int i = 0; i < n; i++) b[i] = sc.nextInt() + 1;
        for (int i = 0; i < n; i++) c[i] = sc.nextInt() + 1;

        for (int i = 0; i < n; i++) acnt[a[i]]++;
        for (int i = 1; i < N; i++) s[i] = s[i - 1] + acnt[i];
        for (int i = 0; i < n; i++) as[i] = s[b[i] - 1];

        for (int i = 0; i < n; i++) ccnt[c[i]]++;
        for (int i = 1; i < N; i++) s[i] = s[i - 1] + ccnt[i];
        for (int i = 0; i < n; i++) cs[i] = s[N - 1] - s[b[i]];

        long res = 0;
        for (int i = 0; i < n; i++) res += (long) as[i] * cs[i];
        System.out.println(res);
    }
}
